package com.lehecai.core.api.openapi;

import java.util.ArrayList;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.lehecai.core.IntegerBeanLabelItem;

/**
 * @author likunpeng
 */
public class DocPosition extends IntegerBeanLabelItem {

	private static final long serialVersionUID = -8013814412345802001L;

	private static final Logger logger = LoggerFactory.getLogger(DocPosition.class.getName());
	
	private static List<DocPosition> items = new ArrayList<DocPosition>();
	private static List<DocPosition> queryItems = new ArrayList<DocPosition>();
	
	protected DocPosition(String name, int value, boolean queryOnly) {
		super(DocPosition.class.getName(), name, value);
		
		queryItems.add(this);
		if (!queryOnly) {
			items.add(this);
		}
	}
	
	protected DocPosition(String name, int value) {
		this(name, value, false);
	}
	
	public static DocPosition getItem(int value){
		try {
			return (DocPosition)DocPosition.getResult(DocPosition.class.getName(), value);
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
			return null;
		}
	}
	
	public static List<DocPosition> getItems() {
		return items;
	}
	
	public static List<DocPosition> getItemsForQuery() {
		return queryItems;
	}

	public static final DocPosition ALL = new DocPosition("全部", -1, true);
	
	public static final DocPosition RECHARGE_PAGE = new DocPosition("充值页面", 1);
	public static final DocPosition HELP = new DocPosition("帮助", 0);
	public static final DocPosition INPUT_BOX = new DocPosition("输入框", 2);
}
